/**************************************************************************
** Yabet is bloging editor tool that supports many blog's formats. It is very usefull for crossposting, allows easily to
** make posts to your blogs.
**
** Copyright (C) 2010 Valery Konchin <eeexception@gmail.com>
**
** This program is free software: you can redistribute it and/or modify
**     it under the terms of the GNU General Public License as published by
**     the Free Software Foundation, either version 3 of the License, or
**     (at your option) any later version.
**
**     This program is distributed in the hope that it will be useful,
**     but WITHOUT ANY WARRANTY; without even the implied warranty of
**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**     GNU General Public License for more details.
**
**     You should have received a copy of the GNU General Public License
**     along with this program.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#include "markuploader.h"
#include <QDir>
#include <QList>
#include "yabettextmarkup.h"
#include "customyabettextmarkup.h"
#include <QApplication>
#include "yabetloghandler.h"

const YabetLogHandler* MarkupLoader::log =  new YabetLogHandler("MarkupLoader");

MarkupLoader::MarkupLoader()
{
    QDir dir(QApplication::applicationDirPath() + QDir::separator() + "markups");

    log->debugMsg("Current markup dir: " + dir.absolutePath());

    dir.setNameFilters(QStringList("*.properties"));

    QList<QString> files = dir.entryList();

    QString fileName;
    foreach(fileName, files) {
        QString fullFileName = dir.absolutePath() + dir.separator() + fileName;
        YabetTextMarkup *markup = new CustomYabetTextMarkup(fullFileName);
        markupsList.insert(markup->getMarkupName(), markup);
    }
}

QMap<QString, YabetTextMarkup*> MarkupLoader::getMarkupsList() {
    return markupsList;
}
